home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Draw / Sources / InsrtCmd.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  3.7 KB  |  122 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                InsrtCmd.cpp
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef INSERTCMD_H
  15. #include "InsrtCmd.h"
  16. #endif
  17.  
  18. #ifndef DRAWSEL_H
  19. #include "DrawSel.h"
  20. #endif
  21.  
  22. #ifndef DRAWFRM_H
  23. #include "DrawFrm.h"
  24. #endif
  25.  
  26. #ifndef DRAWCONT_H
  27. #include "DrawCont.h"
  28. #endif
  29.  
  30. //========================================================================================
  31. // RunTime Info
  32. //========================================================================================
  33.  
  34. #ifdef FW_BUILD_MAC
  35. #pragma segment odfdrawcommand
  36. #endif
  37.  
  38.  
  39. FW_DEFINE_AUTO(CDrawInsertCommand)
  40.  
  41. //========================================================================================
  42. // CDrawInsertCommand
  43. //========================================================================================
  44.  
  45. //----------------------------------------------------------------------------------------
  46. //    CDrawInsertCommand constructor
  47. //----------------------------------------------------------------------------------------
  48.  
  49. CDrawInsertCommand::CDrawInsertCommand(Environment *ev, 
  50.                                         CDrawFrame* frame, 
  51.                                         const FW_PFileSpecification& fileSpec, 
  52.                                         CDrawSelection* selection,
  53.                                         FW_Boolean canUndo) :
  54.     FW_CInsertCommand(ev, frame, fileSpec, canUndo),
  55.     fUndoContent(NULL),
  56.     fDrawSelection(selection)
  57. {
  58.     FW_END_CONSTRUCTOR
  59. }
  60.  
  61. //----------------------------------------------------------------------------------------
  62. //    CDrawInsertCommand destructor
  63. //----------------------------------------------------------------------------------------
  64.  
  65. CDrawInsertCommand::~CDrawInsertCommand()
  66. {
  67.     FW_START_DESTRUCTOR
  68.     delete fUndoContent;
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. //    CDrawInsertCommand::PreCommand
  73. //----------------------------------------------------------------------------------------
  74.  
  75. void CDrawInsertCommand::PreCommand(Environment *ev)
  76. {
  77.     fDrawSelection->CloseSelection(ev);
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81. //    CDrawInsertCommand::CommandDone
  82. //----------------------------------------------------------------------------------------
  83.  
  84. void CDrawInsertCommand::CommandDone(Environment *ev)
  85. {
  86.     fDrawSelection->CenterSelection(ev, GetContextFrame(ev));
  87. }
  88.  
  89. //----------------------------------------------------------------------------------------
  90. //    CDrawInsertCommand::SaveRedoState
  91. //----------------------------------------------------------------------------------------
  92.  
  93. void CDrawInsertCommand::SaveRedoState(Environment *ev)
  94. {
  95.     FW_ASSERT(fUndoContent == NULL);
  96.     fUndoContent = FW_NEW(CDrawUndoContent, (ev, fDrawSelection->GetDrawPart(), fDrawSelection));
  97. }
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    CDrawInsertCommand::FreeRedoState
  101. //----------------------------------------------------------------------------------------
  102.  
  103.  
  104.  
  105. //----------------------------------------------------------------------------------------
  106. //    CDrawInsertCommand::UndoIt
  107. //----------------------------------------------------------------------------------------
  108.  
  109. void CDrawInsertCommand::UndoIt(Environment *ev)
  110. {
  111.     fUndoContent->RemoveShapeSelection(ev);
  112. }
  113.  
  114. //----------------------------------------------------------------------------------------
  115. //    CDrawInsertCommand::RedoIt
  116. //----------------------------------------------------------------------------------------
  117.  
  118. void CDrawInsertCommand::RedoIt(Environment *ev)
  119. {
  120.     fUndoContent->RestoreShapeSelection(ev);
  121. }
  122.